package com.itkm.feignconsumer.service;

import com.itkm.pojo.Comment;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Component
public class CommentClientServiceCallBackFactory implements FallbackFactory<CommentClientService> {
    @Override
    public CommentClientService create(Throwable throwable) {
        return new CommentClientService() {
            @Override
            public List<Comment> getCommentList() {
                return Collections.singletonList(new Comment() {{
                    setId(-1);
                    setContent("查询繁忙，暂时关闭");
                }});
            }

            @Override
            public Comment getCommentById(int id) {
                return new Comment(){{
                    setId(-1);
                    setContent("查询繁忙，暂时关闭");
                }};
            }
        };
    }
}
